package org.tissou.client.Panel_Premier.operations_tab;

import com.google.gwt.user.client.ui.*;
import org.tissou.client.Interface.Base_Panel;
import org.tissou.client.Panel_Premier.operations_tab.Operations.*;

/**
 * Created by IntelliJ IDEA.
 * User: Claire
 * Date: 01-Mar-2009
 * Time: 15:32:29
 * To change this template use File | Settings | File Templates.
 */
public class TAB_Operation extends Base_Panel {
  DockPanel principal = new DockPanel();
  final VerticalPanel radiobuttons = new VerticalPanel();
  VerticalPanel operation = new VerticalPanel();
  final RadioButton achatrecette = new RadioButton("Choix", "Achat / Recette");
  final RadioButton dettes = new RadioButton("Choix", "Pret / Remboursement");
  final RadioButton virementinterne = new RadioButton("Choix", "Virement interne");

  protected void MiseEnPlaceParametresWidgets(){


  }

  protected void MiseEnPlaceStyles(){
    radiobuttons.addStyleName("operationradiobuttons");
    achatrecette.addStyleName("defaultstyle");
    dettes.addStyleName("defaultstyle");
    virementinterne.addStyleName("defaultstyle");
  }

  protected void MiseEnPlaceParametresPanel(){
    radiobuttons.add(achatrecette);
    radiobuttons.add(dettes);
    radiobuttons.add(virementinterne);
}
  protected void MiseEnPlaceActions(){
    ClickListener afficheLeBonPanel = new ClickListener() {
      public void onClick(Widget sender) {
        operation.clear();
        RadioButton rb = (RadioButton)sender;
        if ("Achat / Recette".equals(rb.getText())){
            Operation_AchatRecette op = new Operation_AchatRecette();
            op.afficherDans(operation);
        }
        if ("Pret / Remboursement".equals(rb.getText())){
          Operation_Dette op = new Operation_Dette();
          op.afficherDans(operation);
        }
        if ("Virement interne".equals(rb.getText())){
          Operation_VirementInterne op = new Operation_VirementInterne();
          op.afficherDans(operation);
        }
      }
    };
    achatrecette.addClickListener(afficheLeBonPanel);
    dettes.addClickListener(afficheLeBonPanel);
    virementinterne.addClickListener(afficheLeBonPanel);
   }


  protected void MiseEnPlacePanels(){
    principal.add(radiobuttons, DockPanel.WEST);
    principal.add(operation, DockPanel.WEST);
    principal.setCellHeight(operation, "100%");
    principal.setCellWidth(operation, "100%");

  }

  public Panel donneLePanelPrincipal() {
    return principal;
  }
}
